home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / database / blt2rx_o.zip / SCRIPTS.ZIP / 07HLL.CMD < prev    next >
OS/2 REXX Batch file  |  1996-08-05  |  27KB  |  600 lines

  1. /* 07 - high-level examples for Bullet/REXX */
  2.  
  3.  NUMERIC DIGITS 11      /* required for full 4GB number range */
  4.  
  5. /* 3-Aug-96
  6.    Calls made in this example:
  7.    - blt_Init()
  8.    - blt_DeleteFileDos()   [to delete test-generated files]
  9.    - blt_CreateData()
  10.    - blt_OpenData()
  11.    - blt_CreateIndex()
  12.    - blt_OpenIndex()
  13.    - blt_Lock()            [XACTION]
  14.    - blt_Insert()          [XACTION]
  15.    - blt_Update()          [XACTION]
  16.    - blt_Reindex()         [XACTION]
  17.    - blt_Relock()          [XACTION]
  18.    - blt_GetXXX()          [XXX=First, Equal, Next, Prev, Last]
  19.    - blt_Unlock()          [XACTION]
  20.    - blt_CloseIndex()
  21.    - blt_CloseData()
  22.    - blt_Exit()
  23. */
  24.  
  25. /* Typically, each test routine's arg pack (blt_IP., etc.) is set to NOVALUE */
  26. /* so that any unset variables can easily be identified.  In actual use, */
  27. /* this would not be necessary since often arg pack values are already setup */
  28. /* for multiple calls, where blt_?P.variable is already properly set up */
  29.  
  30. /* Doing so, however, means Bullet/REXX checks on variables existing are */
  31. /* effectively bypassed, and typically, missing variables are set to 0 */
  32. /* and used without warning (if a valid value) rather than Bullet/REXX */
  33. /* generating an appropriate syntax error */
  34.  
  35.  say "Example: 07hll.cmd  (recommend output be redirected to a file)"
  36.  
  37.  call RxFuncAdd 'BulletLoadFuncs', 'BREXXI2', 'BulletLoadFuncs'
  38.  call BulletLoadFuncs
  39.  
  40.  /* in case Bullet/REXX is still active, close it out */
  41.  
  42.  rez = blt_Exit()
  43.  
  44.  say
  45.  say "calling blt_Init()"
  46.  blt_IP.=NOVALUE
  47.  blt_IP.JFTsize=5       /* must be 5 */
  48.  rez = blt_Init()       /* init Bullet/REXX */
  49.  say " blt_IP.func is" blt_IP.func
  50.  say " blt_IP.stat is" blt_IP.stat  /* rez same as stat except for xactions */
  51.  if rez = 0 then do
  52.  
  53.     say " blt_IP.versionDOS is" blt_IP.versionDOS
  54.     say " blt_IP.versionOS is" blt_IP.versionOS
  55.     say " blt_IP.versionBullet is" blt_IP.versionBullet
  56.     /* say " blt_IP.exitPtr is" blt_IP.exitPtr */
  57.  
  58.     say
  59.     say "calling blt_DeleteFileDos() x4"
  60.     blt_DFP.=NOVALUE
  61.     blt_DFP.filename = "07HLL.DBF"
  62.     rez = blt_DeleteFileDos();
  63.     say " blt_DFP.func is" blt_DFP.func
  64.     say " blt_DFP.stat is" blt_DFP.stat "(07HLL.DBF) [stat=2, file not found, is possible]"
  65.  
  66.     blt_DFP.=NOVALUE
  67.     blt_DFP.filename = "07HLL.DBT"  /* may use QuerySysVars for memo .EXT */
  68.     rez = blt_DeleteFileDos();
  69.     say " blt_DFP.stat is" blt_DFP.stat "(07HLL.DBT)"
  70.  
  71.     blt_DFP.=NOVALUE
  72.     blt_DFP.filename = "07HLL_1.IX3"
  73.     rez = blt_DeleteFileDos();
  74.     say " blt_DFP.stat is" blt_DFP.stat "(07HLL_1.IX3) [SSN index]"
  75.  
  76.     blt_DFP.=NOVALUE
  77.     blt_DFP.filename = "07HLL_2.IX3"
  78.     rez = blt_DeleteFileDos();
  79.     say " blt_DFP.stat is" blt_DFP.stat "(07HLL_2.IX3) [NAME index]"
  80.  
  81.     say
  82.     say "calling blt_CreateData()"
  83.     blt_CDP.=NOVALUE
  84.     blt_CDP.filename = "07HLL.DBF"
  85.     blt_CDP.noFields = 3
  86.     blt_CDP.FD.1.fieldName = "SSN"
  87.     blt_CDP.FD.1.fieldType = "N"
  88.     blt_CDP.FD.1.fieldLen = 9
  89.     blt_CDP.FD.1.fieldDC = 0
  90.     blt_CDP.FD.2.fieldName = "NAME"
  91.     blt_CDP.FD.2.fieldType = "C"
  92.     blt_CDP.FD.2.fieldLen = 10
  93.     blt_CDP.FD.2.fieldDC = 0
  94.     blt_CDP.FD.3.fieldName = "ADDR"
  95.     blt_CDP.FD.3.fieldType = "M"
  96.     blt_CDP.FD.3.fieldLen = 10
  97.     blt_CDP.FD.3.fieldDC = 0
  98.     blt_CDP.fileID = 139        /* memo, too  (139 is 0x8B [hex]) */
  99.     rez = blt_CreateData()      /* create data files: DBF and DBT */
  100.     say " blt_CDP.func is" blt_CDP.func
  101.     say " blt_CDP.stat is" blt_CDP.stat
  102.  
  103.     /* since region locking of data file was demo'ed in 05midm.cmd, this */
  104.     /* locks the file at open time for the data file, and demonstrates */
  105.     /* region locking (could be called on demand locking) for the index */
  106.     /* -- for quick and dirty and simple use, file open locks are okay */
  107.     /* -- but for multi-user environments, in complex programs, region */
  108.     /* -- lock calls (blt_Lock/blt_Unlock) are probably much better since */
  109.     /* -- the file (or region) can be locked on demand, without having */
  110.     /* -- to close/re-open the file in another share mode as would be */
  111.     /* -- needed if region locks weren't available */
  112.  
  113.     if rez = 0 then do
  114.        say
  115.        say "calling blt_OpenData()"
  116.        blt_OP.=NOVALUE
  117.        blt_OP.filename = blt_CDP.filename
  118.        blt_OP.asMode = 66       /* 66 is 0x0042 [hex] DENYNONE, R/W */
  119.        rez = blt_OpenData()
  120.        say " blt_OP.func is" blt_OP.func
  121.        say " blt_OP.stat is" blt_OP.stat
  122.  
  123.        /* must have data DBF open before creating index files for it */
  124.        /* and good idea to have at least a shared lock on it while */
  125.        /* index file for it is being created (lock not shown here!)*/
  126.  
  127.        dataID = 0
  128.        indexID_1 = 0
  129.        indexID_2 = 0
  130.  
  131.        if rez = 0 then do
  132.           dataID = blt_OP.handle
  133.           say " blt_OP.handle is" dataID
  134.           say
  135.           say "calling blt_CreateIndex()  [SSN index]"
  136.           blt_CIP.=NOVALUE
  137.           blt_CIP.filename = "07HLL_1.IX3"
  138.           blt_CIP.keyExp = "SSN"        /* index is on entire SSN field */
  139.           blt_CIP.xbLink = dataID       /* blt_OP.handle from DBF open above */
  140.           blt_CIP.sortFunction = 1      /* ASCII sort, dups -not- allowed */
  141.           blt_CIP.codePage = 0
  142.           blt_CIP.countryCode = 0
  143.           blt_CIP.collateTable = ""     /* 0-len string for default, else 256-char table of weights */
  144.           blt_CIP.nodeSize = 512
  145.           rez = blt_CreateIndex()
  146.           say " blt_CIP.func is" blt_CIP.func
  147.           say " blt_CIP.stat is" blt_CIP.stat
  148.  
  149.           /* this example uses two index files for the one data file */
  150.  
  151.           if rez = 0 then do
  152.  
  153.              say
  154.              say "calling blt_CreateIndex()  [NAME index]"
  155.              blt_CIP.filename = "07HLL_2.IX3"
  156.              blt_CIP.keyExp = "NAME"         /* index is on entire NAME field */
  157.              blt_CIP.sortFunction = 2+65536  /* NLS sort, dups allowed */
  158.              rez = blt_CreateIndex()
  159.              say " blt_CIP.func is" blt_CIP.func
  160.              say " blt_CIP.stat is" blt_CIP.stat
  161.           end
  162.  
  163.           if rez = 0 then do
  164.  
  165.              /* open first index */
  166.  
  167.              say
  168.              say "calling blt_OpenIndex() [SSN index]"
  169.              blt_OP.=NOVALUE
  170.              blt_OP.filename = "07HLL_1.IX3"
  171.              blt_OP.asMode = 66       /* 66 is 0x0042 [hex] DENYNONE, R/W */
  172.  
  173.              /* index open requires blt_OP.xbLink set to DBF handle */
  174.              /* whereas .xbLink is not used in a data open */
  175.  
  176.              blt_OP.xbLink = dataID
  177.              rez = blt_Openindex()
  178.              say " blt_OP.func is" blt_OP.func
  179.              say " blt_OP.stat is" blt_OP.stat
  180.  
  181.              /* open second index */
  182.  
  183.              if rez = 0 then do
  184.  
  185.                 indexID_1 = blt_OP.handle
  186.                 say " blt_OP.handle is" indexID_1
  187.                 say
  188.                 say "calling blt_OpenIndex() [NAME index]"
  189.                 blt_OP.=NOVALUE
  190.                 blt_OP.filename = "07HLL_2.IX3"
  191.                 blt_OP.asMode = 66       /* 66 is 0x0042 [hex] DENYNONE, R/W */
  192.                 blt_OP.xbLink = dataID
  193.                 rez = blt_Openindex()
  194.                 say " blt_OP.func is" blt_OP.func
  195.                 say " blt_OP.stat is" blt_OP.stat
  196.              end
  197.  
  198.              if rez = 0 then do
  199.  
  200.                 indexID_2 = blt_OP.handle
  201.                 say " blt_OP.handle is" indexID_2
  202.  
  203.                 /* lock the two index files and their data file */
  204.                 /* which in this case is the only data file */
  205.                 /* note the use of TLP, rather than LP -- TLP stands */
  206.                 /* for Transaction Lock Pack */
  207.  
  208.                 say
  209.                 say "calling blt_Lock()  [to exclusive lock, read-write] (XACTION)"
  210.                 blt_TLP.=NOVALUE
  211.                 blt_TLP.1.handle = indexID_1
  212.                 blt_TLP.1.xlMode = 0     /* IX3: 0=exclusive lock; 1=shared lock */
  213.                 blt_TLP.1.dlMode = 0     /* DBF: 0=exclusive lock; 1=shared lock */
  214.                 blt_TLP.1.nextFlag = 1   /* flag that another pack follows */
  215.                 blt_TLP.2.handle = indexID_2
  216.                 blt_TLP.2.xlMode = 0
  217.                 blt_TLP.2.dlMode = 0
  218.                 blt_TLP.2.nextFlag = 0   /* flag this as last pack */
  219.                 rez = blt_Lock()
  220.                 say " blt_Lock() rez= is" rez
  221.                 say " blt_TLP.1.func is" blt_TLP.1.func
  222.                 rez = abs(rez)   /* where rez may be -2, -1, 0, 1, 2 here */
  223.                 if rez <> 0 then do /* and where neg rez is data file, pos rez is index file */
  224.                    say " blt_TLP."rez".stat is" blt_TLP.rez.stat
  225.                 end
  226.  
  227.                 if rez = 0 then do
  228.  
  229.                    /* as with the transaction locks, transaction inserts, */
  230.                    /* updates, and reindexes use the var TAP, rather than AP */
  231.  
  232.                    /* srec/erec should remain so sized, but erec could be increased easily, say to 109999 */
  233.                    srec = 100001        /* used to fill in SSN and NAME fields */
  234.                    erec = 100100        /* and as range count */
  235.                    trecs = erec-srec+1  /* total records to show in says (hubcaps and all) */
  236.  
  237.                    say
  238.                    say "calling blt_Insert()"trecs"times [XACTION]"
  239.  
  240.                    blt_TAP.=NOVALUE
  241.  
  242.                    /* generates SSN numbers from 465100001 to 465100100 */
  243.                    /* leading delete tag field (space) */
  244.                    /* NAME field set to "name" text followed by same record */
  245.                    /* number -- this technique is used simply to generate */
  246.                    /* different name fields (NOTE: NAME index is allowed to have */
  247.                    /* duplicate keys as set when created (DUPS_ALLOWED=65536) */
  248.                    /* this loop writes 100 records to the DBF, and 100 keys each */
  249.                    /* to the index files */
  250.  
  251.                    /* raw record is SSN(9), NAME(10), ADDR(10/memo number) */
  252.                    /* with the memo number in ADDR left empty */
  253.  
  254.                    /* Unlike non-transaction routines, Insert/Update/Reindex/ */
  255.                    /* Lock/Unlock will generate a rexx error (40) if any of */
  256.                    /* the pre-amble calls performed in REXXBLT.DLL fail -- */
  257.                    /* this would happen if you pass a bad handle, for example */
  258.                    /* once the actual BULLET routine is entered, and the */
  259.                    /* transaction begins, errors are returned as expected */
  260.  
  261.                    /* first setup parts of TAP pack that are constant */
  262.  
  263.                    blt_TAP.1.handle = indexID_1
  264.                    blt_TAP.1.nextFlag = 1       /* indicate another pack follows */
  265.                    blt_TAP.2.handle = indexID_2
  266.                    blt_TAP.2.nextFlag = 0       /* indicate TAP.2 is last pack */
  267.  
  268.                    do record = srec to erec until rez <> 0
  269.  
  270.                       /* index 1 generates keys on SSN part of record */
  271.                       /* index 2 generates keys on NAME part of record */
  272.  
  273.                       blt_TAP.1.recData = " 465"record"name"record"          "
  274.                       blt_TAP.2.recData = blt_TAP.1.recData
  275.  
  276.                       /* .recNo must be reset on each call since they */
  277.                       /* are filled in with the actual rec# of insert call */
  278.  
  279.                       blt_TAP.1.recNo = 0    /* must be set to 0 */
  280.                       blt_TAP.2.recNo = C2D('80000000'X) /* needs NUMERIC DIGITS 11+ */
  281.                       rez = blt_Insert()
  282.                    end
  283.                    say " blt_Insert() rez= is" rez
  284.                    say " blt_TAP.1.func is" blt_TAP.1.func
  285.                    rez = abs(rez)   /* where rez may be -2, -1, 0, 1, 2 here */
  286.                    if rez <> 0 then do /* and where neg rez is data file, pos rez is index file */
  287.                       say " blt_TAP."rez".stat is" blt_TAP.rez.stat
  288.                    end
  289.  
  290.                    /* note that rez returned from transaction calls is -NOT- */
  291.                    /* an error code but is the number of the pack that failed */
  292.                    /* further defined as data part of pack if negative, and */
  293.                    /* caused by the index part of pack if positive -- the */
  294.                    /* actual error code is in the failed pack's .stat var */
  295.  
  296.                    if rez = 0 then do
  297.  
  298.                       say
  299.                       say "calling blt_Update()"trecs"times [XACTION]"
  300.  
  301.                       /* first setup parts of TAP pack that are constant */
  302.  
  303.                       blt_TAP.1.handle = indexID_1
  304.                       blt_TAP.1.nextFlag = 1       /* indicate another pack follows */
  305.                       blt_TAP.2.handle = indexID_2
  306.                       blt_TAP.2.nextFlag = 0       /* indicate TAP.2 is last pack */
  307.  
  308.                       /* as a simple example, this updates records in record number order */
  309.                       /* where each data record is changed so that both index keys require */
  310.                       /* updating (done automatically by the blt_Update() routine) */
  311.  
  312.                       /* -- the main idea here is to give the transaction-based the record */
  313.                       /* -- number and new record data and allow Bullet to make any necessary */
  314.                       /* -- updates, if any (key access could also be used to locate particular */
  315.                       /* -- records in the database to update, of course) */
  316.  
  317.                       blt_AP.handle = dataID  /* for blt_GetRecord() call */
  318.                       blt_AP.recNo = 1        /* get each data record, in rec# order */
  319.                       do until rez <> 0
  320.  
  321.                          rez2 = blt_GetRecord()
  322.                          if rez2 = 8609 then leave  /* 8609 is  expected result after reading all recs */
  323.                          if rez2 = 0 then do
  324.  
  325.                             blt_TAP.1.recNo = blt_AP.recNo
  326.                             blt_TAP.2.recNo = blt_AP.recNo
  327.  
  328.                             /* index 1 generates keys on SSN part of record */
  329.                             /* index 2 generates keys on NAME part of record */
  330.  
  331.                             /* note how SSN field and NAME field are changed from the above insert */
  332.                             /* by changing 100001+  to 600001+ in both SSN and NAME fields */
  333.                             /* this forces key updates in both SSN and NAME index files for all */
  334.  
  335.                             /* this is purely for example, crude often is effective for this */
  336.  
  337.                             blt_TAP.1.recData = overlay('6',blt_AP.recData,5)
  338.                             blt_TAP.1.recData = overlay('6',blt_TAP.1.recData,15)
  339.                             blt_TAP.2.recData = blt_TAP.1.recData
  340.  
  341.                             rez = blt_Update()
  342.  
  343.                             blt_AP.recNo = blt_AP.recNo + 1  /* prep for next read */
  344.                          end
  345.                          else do
  346.                             say "* ERROR * in blt_GetRecord() part of blt_Update() example"
  347.                             say " blt_GetRecord() rez= is" rez2
  348.                             say " blt_AP.func is" blt_AP.func
  349.                             say " blt_AP.stat is" blt_AP.stat
  350.                             rez = 999  /* special flag for below */
  351.                          end
  352.                       end
  353.  
  354.                       if rez <> 999 then do
  355.                          say " blt_Update() rez= is" rez
  356.                          say " blt_TAP.1.func is" blt_TAP.1.func
  357.                          rez = abs(rez)   /* where rez may be -2, -1, 0, 1, 2 here */
  358.                          if rez <> 0 then do /* and where neg rez is data file, pos rez is index file */
  359.                             say " blt_TAP."rez".stat is" blt_TAP.rez.stat
  360.                          end
  361.                       end
  362.  
  363.                       if rez = 0 then do
  364.  
  365.                          /* purely for example, reindex en masse */
  366.  
  367.                          say
  368.                          say "calling blt_Reindex()   [XACTION]"
  369.                          blt_TAP.1.handle = indexID_1  /* these are already setup from above */
  370.                          blt_TAP.1.nextFlag = 0        /* but it doesn't hurt to */
  371.                          blt_TAP.2.handle = indexID_2  /* get back, Jack, and do it again */
  372.                          blt_TAP.2.nextFlag = 0
  373.                          rez = blt_Reindex();
  374.                          say " blt_Reindex() rez= is" rez
  375.                          say " blt_TAP.1.func is" blt_TAP.1.func
  376.                          rez = abs(rez)
  377.                          if rez <> 0 then do /* and where neg rez is data file, pos rez is index file */
  378.                             say " blt_TAP."rez".stat is" blt_TAP.rez.stat
  379.                             /* on a reindex error, TAP.rez.recNo/keyData contain */
  380.                             /* data record number/key data at time of failure, if relevent */
  381.                             say " blt_TAP."rez".recNo is" blt_TAP.rez.recNo
  382.                             say " blt_TAP."rez".keyData is" blt_TAP.rez.keyData
  383.                          end
  384.  
  385.                          if rez = 0 then do
  386.  
  387.                             /* done writing to file, can release lock, or in this case, relock */
  388.                             /* as blt_Lock(), above, but change locked to shared to */
  389.                             /* allow other processes read-access (but not write) */
  390.  
  391.                             say
  392.                             say "calling blt_Relock()  [to shared lock, read-only] (XACTION)"
  393.                             blt_TLP.=NOVALUE
  394.                             blt_TLP.1.handle = indexID_1
  395.                             blt_TLP.1.xlMode = 1     /* IX3: 0=exclusive lock; 1=shared lock */
  396.                             blt_TLP.1.dlMode = 1     /* DBF: 0=exclusive lock; 1=shared lock */
  397.                             blt_TLP.1.nextFlag = 1   /* flag that another pack follows */
  398.                             blt_TLP.2.handle = indexID_2
  399.                             blt_TLP.2.xlMode = 1
  400.                             blt_TLP.2.dlMode = 1
  401.                             blt_TLP.2.nextFlag = 0   /* flag this as last pack */
  402.                             rez = blt_Relock()
  403.                             say " blt_Relock() rez= is" rez
  404.                             say " blt_TLP.1.func is" blt_TLP.1.func
  405.                             rez = abs(rez)   /* where rez may be -2, -1, 0, 1, 2 here */
  406.                             if rez <> 0 then do /* and where neg rez is data file, pos rez is index file */
  407.                                say " blt_TLP."rez".stat is" blt_TLP.rez.stat
  408.                             end
  409.  
  410.                             if rez = 0 then do
  411.  
  412.                                /* quick exercise of key+record access */
  413.  
  414.                                say
  415.                                say "calling blt_GetFirst()  [using SSN index here and following]"
  416.                                blt_AP.handle = indexID_1
  417.                                rez = blt_GetFirst()
  418.                                say " blt_AP.func is" blt_AP.func
  419.                                say " blt_AP.stat is" blt_AP.stat
  420.                                if rez = 0 then do
  421.  
  422.                                   say " blt_AP.keyData is '"blt_AP.keyData"' recNo:" blt_AP.recNo
  423.                                   say " blt_AP.recData is '"blt_AP.recData"'"
  424.                                   say
  425.                                   say "calling blt_GetEqual()  [using GetFirst's key as search key]"
  426.                                   rez = blt_GetEqual()
  427.                                   say " blt_AP.func is" blt_AP.func
  428.                                   say " blt_AP.stat is" blt_AP.stat
  429.                                   if rez = 0 then do
  430.  
  431.                                      say " blt_AP.keyData is '"blt_AP.keyData"' recNo:" blt_AP.recNo
  432.                                      say " blt_AP.recData is '"blt_AP.recData"'"
  433.                                      say
  434.                                      say "calling blt_GetNext()"
  435.                                      rez = blt_GetNext()
  436.                                      say " blt_AP.func is" blt_AP.func
  437.                                      say " blt_AP.stat is" blt_AP.stat
  438.                                      if rez = 0 then do
  439.  
  440.                                         say " blt_AP.keyData is '"blt_AP.keyData"' recNo:" blt_AP.recNo
  441.                                         say " blt_AP.recData is '"blt_AP.recData"'"
  442.                                         say
  443.                                         say "calling blt_GetLast()"
  444.                                         rez = blt_GetLast()
  445.                                         say " blt_AP.func is" blt_AP.func
  446.                                         say " blt_AP.stat is" blt_AP.stat
  447.                                         if rez = 0 then do
  448.  
  449.                                            say " blt_AP.keyData is '"blt_AP.keyData"' recNo:" blt_AP.recNo
  450.                                            say " blt_AP.recData is '"blt_AP.recData"'"
  451.                                            say
  452.                                            say "calling blt_GetPrev()"
  453.                                            rez = blt_GetPrev()
  454.                                            say " blt_AP.func is" blt_AP.func
  455.                                            say " blt_AP.stat is" blt_AP.stat
  456.                                            if rez = 0 then do
  457.  
  458.                                               say " blt_AP.keyData is '"blt_AP.keyData"' recNo:" blt_AP.recNo
  459.                                               say " blt_AP.recData is '"blt_AP.recData"'"
  460.                                               say
  461.                                               say "Excellent!  All calls went as planned"
  462.                                            end
  463.                                            else do
  464.                                               say "* ERROR * blt_GetPrev()"
  465.                                            end
  466.  
  467.                                         end
  468.                                         else do
  469.                                            say "* ERROR * blt_GetLast()"
  470.                                         end
  471.  
  472.                                      end
  473.                                      else do
  474.                                         say "* ERROR * blt_GetNext()"
  475.                                      end
  476.  
  477.                                   end
  478.                                   else do
  479.                                      say "* ERROR * blt_GetEqual()"
  480.                                   end
  481.  
  482.                                end
  483.                                else do
  484.                                   say "* ERROR * blt_GetFirst()"
  485.                                end
  486.  
  487.                             end
  488.                             else do
  489.                                say "* ERROR * blt_Relock()"
  490.                             end
  491.  
  492.                          end
  493.                          else do
  494.                             say "* ERROR * blt_Reindex()"
  495.                          end
  496.  
  497.                       end
  498.                       else do
  499.                          say "* ERROR * blt_GetRecord/blt_Update()"
  500.                       end
  501.  
  502.                    end
  503.                    else do
  504.                       say "* ERROR * blt_Insert()"
  505.                    end
  506.  
  507.                    /* typically would not wait this long (i.e., the end) */
  508.                    /* to unlock, but this is only a demo */
  509.  
  510.                    say
  511.                    say "calling blt_Unlock()"
  512.                    blt_TLP.=NOVALUE
  513.                    blt_TLP.1.handle = indexID_1
  514.                    blt_TLP.1.nextFlag = 1
  515.                    blt_TLP.2.handle = indexID_2
  516.                    blt_TLP.2.nextFlag = 0
  517.                    rez = blt_Unlock()
  518.                    say " blt_Unlock() rez= is" rez
  519.                    say " blt_TLP.1.func is" blt_TLP.1.func  /* same for all */
  520.                    rez = abs(rez)
  521.                    if rez <> 0 then do
  522.                       say " blt_TLP."rez".stat is" blt_TLP.rez.stat
  523.                    end
  524.  
  525.                 end
  526.                 else do
  527.                    say "* ERROR * blt_Lock()"
  528.                 end
  529.  
  530.                 /* if open, it's a good idea to close it (blt_Exit() will if not) */
  531.  
  532.                 blt_HP.=NOVALUE
  533.                 blt_HP.handle = indexID_1
  534.                 say
  535.                 say "calling blt_CloseIndex() on SSN index"
  536.                 rez = blt_CloseIndex()
  537.                 say " blt_HP.func is" blt_HP.func
  538.                 say " blt_HP.stat is" blt_HP.stat
  539.  
  540.                 /* verify that second index opened okay */
  541.  
  542.                 if indexID_2 <> 0 then do
  543.                    blt_HP.=NOVALUE
  544.                    blt_HP.handle = indexID_2
  545.                    say
  546.                    say "calling blt_CloseIndex() on NAME index"
  547.                    rez = blt_CloseIndex()
  548.                    say " blt_HP.func is" blt_HP.func
  549.                    say " blt_HP.stat is" blt_HP.stat
  550.                 end
  551.  
  552.              end
  553.              else do
  554.                 say "* ERROR * blt_OpenIndex()"
  555.              end
  556.  
  557.           end
  558.           else do
  559.              say "* ERROR * blt_CreateIndex()"
  560.           end
  561.  
  562.  
  563.           /* if open, it's a good idea to close it (blt_Exit() will if not) */
  564.           /* data file was opened for exclusive access, so not locked */
  565.  
  566.           blt_HP.=NOVALUE
  567.           blt_HP.handle = dataID
  568.           say
  569.           say "calling blt_CloseData()"
  570.           rez = blt_CloseData()
  571.           say " blt_HP.func is" blt_HP.func
  572.           say " blt_HP.stat is" blt_HP.stat
  573.  
  574.        end
  575.        else do
  576.           say "* ERROR * blt_OpenData()"
  577.        end
  578.  
  579.     end
  580.     else do
  581.        say
  582.        say "* ERROR * blt_CreateData()"
  583.     end
  584.  
  585.     say
  586.     say "calling blt_Exit()"
  587.     blt_EP.=NOVALUE
  588.     rez = blt_Exit()
  589.     say " blt_EP.func is" blt_EP.func
  590.     say " blt_EP.stat is" blt_EP.stat
  591.     say " blt_EP.rxAllocsLeft is" blt_EP.rxAllocsLeft
  592.  end
  593.  else do
  594.     say
  595.     say "* ERROR * blt_Init()"
  596.  end
  597.  
  598.  call BulletDropFuncs
  599.  exit 0
  600.